package response;

import java.io.IOException;

import core.Constants;
import core.GamePacket;
import core.GameUser;

/**
 * According to the public chat request, this is the response
 * to broadcast the message to other users
 *
 * @author gary
 *
 */
public class ResponseChatPublic extends GameResponse {

    private GameUser user;
    private String message;

    public void setUser(GameUser user) {
        this.user = user;
    }

    public void setContent(String message) {
        this.message = message;
    }

    @Override
    public byte[] createResponse() {
        GamePacket packet = new GamePacket(code);
        packet.addUint32(user.getID());
        packet.addString(user.getUsername());
        packet.addString(message);

        return packet.getBytes();
    }
}